package com.android.library.utils;

import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * @author xiaoxing
 * Created by pengsheng-2 on 2018/6/11.
 */

public class TimeUtil {
    /**
     * 把timestamp各式化成yyyy/MM/dd
     * @param time
     * @param inFormat;
     * @return
     */
    public static String dateString(long time,String inFormat) {
        return android.text.format.DateFormat.format(inFormat, time*1000L).toString();
    }

    /**
     * 把timestamp各式化成yyyy/MM/dd
     * @param strTime
     * @param inFormat;
     * @return
     */
    public static String dateString(String strTime,String inFormat) {
        if (strTime == null){
            return "0";
        }
        try {
            long time = Long.parseLong(strTime)/1000;
            return android.text.format.DateFormat.format(inFormat, time*1000L).toString();
        }catch (Exception e){
            return "0";
        }
    }

}
